<?php
$postid = $_GET['Post'];
$count = $blog->GetPostCount(1, $cat, $keyword, '', $status, $cat1FID);
$postinfo = $blog->GetPosts($postid);//提取文章信息
if(!$postinfo){
	echo "无此文章";
	exit();
}

//更新文章访问次数
$blog->UpdatePostView($postid);
$status = 0;

if(!isset($_SESSION['User_F_ID'])){
	$status = 1;
	if($postinfo['F_POSTS_STATUS']!=1){
		echo "对不起，你无权访问此文章";
		exit();
	}
}else{
	if(!($blog_user['F_ID_USER_INFO']==$_SESSION['User_F_ID']))
	{
		$status = 2;
		if($postinfo['F_POSTS_STATUS']!=1 && $postinfo['F_POSTS_STATUS']!=2)
		{
			echo "对不起，你无权访问此文章";
			exit();
		}
	}
}

if($postinfo['F_POSTS_IS_COMMENTED'] && $blog_info['F_BLOG_PERM_COMMENTS'])//判断该博客和文章是否可评论
{
	$page = $_GET['Page'];
	if(!$page)$page=1;
	$com_list = $blog->GetCommentsList(1, $postid);//提取评论列表
	$count = $blog->GetCommentsCount($postid); //提取评论条数
	//$pagecount = ceil($count/$blog->pagesize);//计算评论页数
	//if(!$pagecount) $pagecount = 1;
}
?><div id="content"><div class="pagination cut-off-bottom"><a href="index.php?Action=Post&amp;Post=<?php echo ($postid - 1) ?>" title="css选择器及其优先级">上一篇</a> <a href="index.php?Action=Post&amp;Post=<?php echo ($postid + 1) ?>">下一篇</a> <a href="index.php">返回</a></div><div id="book">
<div class="chapter">
<h3><span class="option" title="you can opt for turn off the chapter or not"></span><a href="javascript" title="css选择器及其优先级" class="current"><?php echo $postinfo['F_POSTS_TITLE'] ?></a><span class="date"><?php echo date("Y-m-d", $postinfo['F_POSTS_ISSUE_DATE']) ?></span><span class="time"><?php echo date("H:i", $postinfo['F_POSTS_ISSUE_DATE']) ?></span></h3><div class="chapter-body"><div class="add-ons"><span class="rside"><label>评论：(<em><?php echo $postinfo['F_POSTS_COMMENTS'] ?></em>)</label><label>浏览：(<em><?php echo $postinfo['F_POSTS_VIEWS'] ?></em>)</label></span><span><label>分类：<a href="index.php?Cat=<?php echo $postinfo['CatId'] ?>"><?php echo $postinfo['F_CATEGORIES_NAME'] ?></a></label></span></div><?php echo $postinfo['F_POSTS_CONTENTS'] ?></div></div><div class="pagination cut-off-top"><a href="index.php?Action=Post&amp;Post=<?php echo ($postid - 1) ?>" title="css选择器及其优先级">上一篇</a> <a href="index.php?Action=Post&amp;Post=<?php echo ($postid + 1) ?>">下一篇</a> <a href="index.php">返回</a></div>
<div id="comments">
<?php
if($com_list)
{
?>
<h3>评论：<em><?php echo $count ?></em></h3><ul id="comments-list"><?php
foreach($com_list as $com){
	if(empty($com['F_COMMENTS_USER_BLOG'])){
		echo <<<EOFORM
<li><font>{$com['F_COMMENTS_USER']}：</font>
EOFORM;
	}else{
		echo <<<EOFORM
<li><font><a target="_blank" href="{$com['F_COMMENTS_USER_BLOG']}">{$com['F_COMMENTS_USER']}</a>：</font>
EOFORM;
	}
	$commentsDate = date('Y-m-d', $com['F_COMMENTS_DATE']);
	$commentsTime = date('H:i:s', $com['F_COMMENTS_DATE']);
	echo <<<EOFORM
<p>{$com['F_COMMENTS_CONTENT']} <span class="date">{$commentsDate}</span> <span class="time">{$commentsTime}</span></p></li>
EOFORM;
}
}
?></ul>
<div id="comments-pub">
<form id="commentsForm" method="post" action="Comments.php?ReturnUrl=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>" >
<h4>发表评论</h4>
<table>
  <tbody>
	<tr>
<?php
if(isset($_SESSION['User_Name']))
{
	echo <<<EOFORM
<th width="160"><em>*</em> Blog主人：</th><td>{$user_info['F_USER_NICKNAME']}</td>
EOFORM;
}else{
	echo <<<EOFORM
<th width="160"><em>*</em>您的网名：</th>
<td><input type="text" class="text" name="username" id="username"></td>
EOFORM;
}
?>
	</tr>
    <tr>
		<th valign="top"><em>*</em>您的Email：</th>
		<td><input type="text" class="text" name="useremail" id="useremail" ></td>
	</tr>
    <tr>
		<th valign="top">网站/blog：</th>
		<td><input type="text" class="text" name="userwebsite" id="userwebsite" ></td>
	</tr>
	<tr>
		<th valign="top"><em>*</em>想说的话：</th>
		<td><textarea name="contents" id="contents" cols="70" rows="6"></textarea></td>
	</tr>
	<tr>
  	<th></th>
    <td>
		<input type="submit" class="submit" name="Submit" id="commentsSub" style="height:30px; width:60px;" value="提 交">
		<input name="postid" type="hidden" id="postid" value="<?php echo $postid?>">
    </td>
	</tr>
</tbody>
</table>
</form></div></div>
</div>
</div>
<div id="sidebar"><?php require_once("sidebar.php") ?></div>